package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TPatentInfo;
import cn.com.headfree.mouldshow.dao.TPatentInfoDao;
import cn.com.headfree.vo.simple.PatentInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tPatentInfoDao")
public class TPatentInfoDaoImpl extends BaseDaoImpl<TPatentInfo> implements TPatentInfoDao {


    @Override
    public List<PatentInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params=new Object[1];
//        StringBuilder sql=new StringBuilder("select t.id,t.patent_name,t.patent_no,GET_DIC('AcademicDegree',t.patent_type) as patent_type,t.apply_date,DATE_FORMAT(t.apply_date,'%Y-%m-%d %H:%i:%s') as apply_date_str,t.decl_date,DATE_FORMAT(t.decl_date,'%Y-%m-%d %H:%i:%s') as decl_date_str,u.xb_name as user_name,p.erp_no,p.rank from t_patent_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on p.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.apply_date DESC");
//        StringBuilder sql=new StringBuilder("select t.id,t.patent_name,t.patent_no,GET_DIC('AcademicDegree',t.patent_type) as patent_type,t.apply_date,DATE_FORMAT(t.apply_date,'%Y-%m-%d %H:%i:%s') as apply_date_str,t.decl_date,DATE_FORMAT(t.decl_date,'%Y-%m-%d %H:%i:%s') as decl_date_str,u.`NAME` as user_name,p.erp_no,p.rank from t_patent_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on p.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.apply_date DESC");
//        StringBuilder sql=new StringBuilder("select t.id,t.patent_name,t.patent_no,GET_DIC('AcademicDegree',t.patent_type) as patent_type,t.apply_date,t.decl_date,u.`NAME` as user_name,p.erp_no,p.rank from t_patent_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on p.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.apply_date DESC");
        StringBuilder sql=new StringBuilder("select t.id,t.patent_name,t.patent_no,t.patent_type,t.apply_date,t.decl_date,u.`NAME` as user_name,p.erp_no,p.rank from t_patent_info t INNER JOIN t_part_rank p on t.id=p.item_id INNER JOIN t_dept_emp_rela d on p.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on p.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.apply_date DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(PatentInfoVo.class, sql.toString(), null, false, params);
    }
}
